package com.wujie.activies.service.imp;

import com.wujie.activies.dao.ActivityMapper;
import com.wujie.activies.model.Activity;
import com.wujie.activies.model.ActivityExample;
import com.wujie.activies.service.IActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by yudongyang on 2015/12/11.
 */
@Service("activityService")

public class ActivityServiceImpl implements IActivityService {

    @Autowired
    private ActivityMapper activityMapper;

    @Override
    public List<Activity> getAll() {
        ActivityExample activityExample = new ActivityExample();
        return activityMapper.selectByExample(activityExample);
    }

    @Override
    public int deleteByPrimaryKey(Integer key) {
        return activityMapper.deleteByPrimaryKey(key);
    }

    @Override
    public Activity getByPrimaryKey(Integer key) {
        return activityMapper.selectByPrimaryKey(key);
    }

    @Override
    public List<Activity> getByInstance(Activity ele) {
        ActivityExample ae = new ActivityExample();
        ae.createCriteria().andNameEqualTo(ele.getName())
                .andBgtmEqualTo(ele.getBgtm()).andEdtmEqualTo(ele.getEdtm());
        return activityMapper.selectByExample(ae);
    }

    @Override
    public int updateByPrimaryKey(Activity ele) {
        return activityMapper.updateByPrimaryKeySelective(ele);
    }

    @Override
    public int insertSelective(Activity ele) {
        return activityMapper.insertSelective(ele);
    }

}
